from django.db import models


class ContacterGroup( models.Model ):
    name = models.CharField( max_length = 200 )
    
    def __unicode__( self ):
        return self.name

class ContacterTitle( models.Model ):
    name = models.CharField( max_length = 200 )
    
    def __unicode__( self ):
        return self.name

class ContacterDepartment( models.Model ):
    name = models.CharField( max_length = 200 )

    def __unicode__( self ):
        return self.name
    
class Contacter( models.Model ):
    name = models.CharField( max_length = 200 )
    group = models.ForeignKey( ContacterGroup )
    title = models.ForeignKey( ContacterTitle )
    department = models.ForeignKey( ContacterDepartment )
    email1 = models.CharField( max_length = 200, blank = True, null = True )
    email2 = models.CharField( max_length = 200, blank = True, null = True )
    phone1 = models.CharField( max_length = 200, blank = True, null = True )
    phone2 = models.CharField( max_length = 200, blank = True, null = True )
    address1 = models.CharField( max_length = 200, blank = True, null = True )
    postcode = models.CharField( max_length = 200, blank = True, null = True )
    
    address2 = models.CharField( max_length = 200, blank = True, null = True )
    company = models.CharField( max_length = 200, blank = True, null = True )
    website = models.CharField( max_length = 200, blank = True, null = True )

    qq = models.CharField( max_length = 200, blank = True, null = True )
    msn = models.CharField( max_length = 200, blank = True, null = True )
    other = models.TextField( null=True, blank=True )
    
    def __unicode__( self ):
        return self.name

class Contact( models.Model ):
    contacter = models.ForeignKey( Contacter )
    time = models.DateTimeField()
    event = models.CharField( max_length = 200 )
    detail = models.TextField( null = True, blank = True )
    
    def __unicode__( self ):
        return "[%s]%s" % ( self.contacter.name, self.event )
    
    